package org.huntaway.lucene.demo;

import java.io.File;
import java.io.IOException;
import java.util.Date;

import org.huntaway.kernel.NutException;
import org.huntaway.lucene.base.BaseIndex;
import org.huntaway.lucene.demo.util.IndexDocList;

public class IndexFiles extends BaseIndex {
	private IndexFiles() {
	}

	// static final String INDEX_DIR = "I:/jskyme/org.apache.lucene/huntaway/";

	public static void main(String[] args) {
		IndexFiles indexFile = new IndexFiles();
		// indexFile.doIndex();
		indexFile.doIndexOne();
	}

	private void doIndexOne() {
		// docsLst = IndexDocList.getCompanyList();
		// INDEX_DIR = IndexDocList.getCompanyIndex();
		docsLst = IndexDocList.getWorkDocList();
		INDEX_DIR = IndexDocList.getWorkIndex();
		logln(" root Indexing directory is '" + INDEX_DIR + "'...");
		Date start = new Date();
		int i = 0;
		for (String docItem : docsLst) {
			File docDir = new File(docItem);
			try {
				//indexDocByRaw(docDir, i++ == 0);
				indexDocByRaw(docDir, false);
				logln("Lucene is finished...");
			} catch (IOException e) {
				e.printStackTrace();
				logln(" caught a " + e.getClass() + "\n with message: "
						+ e.getMessage());
			} catch (NutException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		Date end = new Date();
		logln(end.getTime() - start.getTime() + " total milliseconds");

	}
}
